package com.controller;

import com.model.Balance;
import com.service.BalanceService;
import com.tool.ResponseMessage;
import com.tool.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 编写者：张佳齐
 * 编写时间：2019-5-29
 * 类模块描述：查询及相关增删改
 */
@RestController(value = "/Balance")
public class BalanceController {
    @Autowired
    private BalanceService balanceService;
    /*查询数据*/
    @CrossOrigin/*跨越访问*/
    @RequestMapping(value = "/getBid")
    public Balance getUid(int bid){
        return balanceService.selectByPrimaryKey(bid);
    }
    /*查询数据*/
    @CrossOrigin/*跨越访问*/
    @RequestMapping(value = "/getAllB")
    public ResponseMessage getB(){
        System.out.println("调用角色全部信息");
        Map<String, List> map = new HashMap<>();
        map.put("list",balanceService.getAllB());
        return Result.success("200",map);}
    /*删除数据*/
    @CrossOrigin /*跨越访问*/
    @RequestMapping(value = "delB",method = RequestMethod.GET)
    public int delB (int bid){return balanceService.delB(bid);}
    /*添加数据*/
    @CrossOrigin/*跨越访问*/
    @RequestMapping(value = "addB",method = RequestMethod.PUT)
    public int addB(@RequestBody Balance balancemodel){
        if (balancemodel!=null){}
        else
        {}
        return balanceService.insertB(balancemodel);}
}
